

import React, { Component } from 'react';
import Son from "./Son"

export default class index extends Component {
    constructor(props){
        super(props);
        this.child = React.createRef();
    }

    chuanToSon=()=>{
      this.child.current.chuan("呵呵");
    }

  render() {    
    return (
      <div>
        <h1>父组件---子组件（使用ref）</h1>
        <input type="button" value="传给子" onClick={this.chuanToSon} />
        <hr/>
        <Son ref={this.child} ></Son>

      </div>
    )
  }
}
